/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.osdtsystem.functions;

import org.osdtsystem.graphs.GraphAccessor;

/**
 *
 * @author matthias
 */
public class FuncEquals<V> extends AbstractSingletonFunction<Boolean> {
    SingletonFunction<V> arg1, arg2;

    FuncEquals(SingletonFunction<V> arg1, SingletonFunction<V> arg2) {
        super(arg1, arg2);
        this.arg1 = arg1;
        this.arg2 = arg2;
    }

    @Override
    public Boolean _singletonFunctionValue(LocalFunction<?, ?> caller, FunctionContext context, GraphAccessor accessor) {
        V value1 = arg1.singletonFunctionValue(caller, context, accessor);
        V value2 = arg2.singletonFunctionValue(caller, context, accessor);
        return (value1 != null && value1.equals(value2)) ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    void toStringBuilder(FunctionStringBuilder builder) {
        builder.addSubfunctions(arg1, arg2);
    }
}
